//
//  LGCarePlanTaskHeadView.m
//  HeartDiseaseManage
//
//  Created by 1234 on 2023/9/19.
//  新增、编辑任务 -- 区头

#import "LGCarePlanTaskHeadView.h"

@interface LGCarePlanTaskHeadView()
/**   */
@property (nonatomic , strong)UIView *baseView;
/**   */
@property (nonatomic , strong)UIImageView *iconView;
/**   */
@property (nonatomic , strong)UILabel *titleLabel;
/**   */
@property (nonatomic , strong)UILabel *subTitleLabel;
/**   */
@property (nonatomic , strong)UITextField *contentTF;
/**   */
@property (nonatomic , strong)UIImageView *tipView;
/**   */
@property (nonatomic , strong)UIView *lineView;

@end

@implementation LGCarePlanTaskHeadView

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self createSubView];
    }
    return self;
}

-(void)setTitle:(NSString *)title{
    _title = title;
    self.iconView.image = [UIImage imageNamed:[NSString stringWithFormat:@"编辑任务-%@",title]];
    self.titleLabel.text = title;
}

-(void)setSubTitle:(NSString *)subTitle{
    _subTitle = subTitle;
    self.subTitleLabel.text = subTitle;
}

-(void)setContent:(NSString *)content{
    _content = content;
    self.contentTF.text = content;
}

-(void)setShowTip:(BOOL)showTip{
    _showTip = showTip;
    self.contentTF.hidden = !showTip;
    self.tipView.hidden = !showTip;
    self.lineView.hidden = showTip;
}

#pragma mark
#pragma mark ====> 创建控件
-(void)createSubView{
    self.clipsToBounds = YES;
    self.backgroundColor = [UIColor clearColor];
    [self addSubview:self.baseView];
    [self.baseView addSubview:self.iconView];
    [self.baseView addSubview:self.titleLabel];
    [self.baseView addSubview:self.subTitleLabel];
    [self.baseView addSubview:self.contentTF];
    [self.baseView addSubview:self.tipView];
    [self.baseView addSubview:self.lineView];
    [self.baseView addSubview:self.actionBtn];
    [self.baseView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.equalTo(self).offset(viewPix(8));
        make.left.equalTo(self).offset(viewPix(16));
        make.right.equalTo(self).offset(-viewPix(16));
    }];
    [self.iconView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.baseView).offset(viewPix(20));
        make.top.left.equalTo(self.baseView).offset(viewPix(12));
        make.width.height.equalTo(@(viewPix(24)));
    }];
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.iconView.mas_right).offset(viewPix(6));
        make.centerY.equalTo(self.iconView);
    }];
    [self.subTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.titleLabel.mas_right).offset(viewPix(6));
        make.centerY.equalTo(self.titleLabel);
    }];
    [self.contentTF mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.tipView.mas_left).offset(-viewPix(2));
        make.centerY.equalTo(self.iconView);
        make.width.equalTo(@(viewPix(200)));
        make.height.equalTo(@(viewPix(40)));
    }];
    [self.tipView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.baseView).offset(-viewPix(12));
        make.width.height.equalTo(@(viewPix(12)));
        make.centerY.equalTo(self.iconView);
    }];
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.baseView).offset(viewPix(12));
        make.right.equalTo(self.baseView).offset(-viewPix(12));
        make.top.equalTo(self.baseView).offset(viewPix(46));
        make.height.equalTo(@(0.5));
    }];
    [self.actionBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.bottom.right.equalTo(self.baseView);
    }];
}
    
-(UIView *)baseView{
    if(!_baseView){
        _baseView = [UIView shadowViewWithColor:@"#B3C5D9" offset:CGSizeMake(0, 2) opacity:0.15 radius:12];
        _baseView.backgroundColor = [UIColor whiteColor];
    }
    return _baseView;
}

-(UIImageView *)iconView{
    if(!_iconView){
        _iconView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@""]];
    }
    return _iconView;
}

-(UILabel *)titleLabel{
    if(!_titleLabel){
        _titleLabel = [UILabel lableWithText:@"" colorString:@"#333333" textFont:LGFontWeight(15, UIFontWeightMedium) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _titleLabel;
}

-(UILabel *)subTitleLabel{
    if(!_subTitleLabel){
        _subTitleLabel = [UILabel lableWithText:@"" colorString:@"#666666" textFont:LGFont(16) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _subTitleLabel;
}

-(UITextField *)contentTF{
    if(!_contentTF){
        _contentTF = [[UITextField alloc]init];
        _contentTF.tintColor = [UIColor colorWithString:@"#000000"];
        _contentTF.textColor = [UIColor colorWithString:@"#000000"];
        _contentTF.textAlignment = NSTextAlignmentRight;
        _contentTF.placeholder = @"请选择";
        _contentTF.font = LGFont(16);
        _contentTF.userInteractionEnabled = NO;
    }
    return _contentTF;
}

-(UIImageView *)tipView{
    if(!_tipView){
        _tipView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"grayTip12"]];
    }
    return _tipView;
}

-(UIView *)lineView{
    if(!_lineView){
        _lineView = [[UIView alloc] init];
        _lineView.backgroundColor = [UIColor colorWithString:@"#E8E8E8"];
    }
    return _lineView;
}

-(UIButton *)actionBtn{
    if(!_actionBtn){
        _actionBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    }
    return _actionBtn;
}

@end
